/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Day09_SlideExamples;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Mark
 */
public class GenericList
{

    /**
     * @param args the command line arguments
     */
    @SuppressWarnings("rawtypes")
	public static void main(String[] args)
    {

//Traditional use of a List
        List myWeeList1 = new ArrayList();
        myWeeList1.add(new Integer(2));
        Integer x1 = (Integer) myWeeList1.get(0); //cast required

        System.out.println(x1);

//-------------------------------------
//Generic approach
        List<Integer> myWeeList2 = new ArrayList<Integer>();
        myWeeList2.add(new Integer(2));
        Integer x2 = myWeeList2.get(0);

        System.out.println(x2);


//Generic Array List to hold Strings
        ArrayList<String> strings = new ArrayList<String>();
        strings.add("hi");
        strings.add("there");
        String s = strings.get(0); // again, no cast required!
        System.out.println(s);
    
        
    
    }
}
